package com.hyf.dao.impl;

import com.hyf.dao.AccountDao;
import org.springframework.jdbc.core.JdbcTemplate;

public class AccountDaoImpl implements AccountDao {
    private JdbcTemplate jdbcTemplate;
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate){
        this.jdbcTemplate = jdbcTemplate;
    }
    @Override
    public  int updateAddMoneyByName(String name,double money){
        String sql = "update account set money = money + ? where name = ?";
        return jdbcTemplate.update(sql,money,name);
    }
    @Override
    public int updateSubMoneyByName(String name,double money){
        String sql = "update account set money = money - ? where name = ?";
        return jdbcTemplate.update(sql,money,name);
    }
}
